/**
 * 页面控件初始化
 * * */
(function(doc,$){
    //Industry
    var $postionCate = $('#desired_Jobtype_container'), $doc = $(doc);
    //职位类别包装函数
    $.fn.industryCreator = function(containerid,isMultiSelect,selectedMaxNum,showNamesElemId,showIdsElemId,showParentIdsElemId,confimFun,cancelFun){
        var cateUrl = '';
        if(language && language == 2){
            cateUrl = 'http://i.zhaopin.com/Content/pop/jobCateSelect_en.html';
        }else{
            cateUrl = 'http://i.zhaopin.com/Content/pop/jobCateSelect.html';
        }
        $.ajax({
            url : cateUrl,
            dataType : "html",
            async: false,
            success : function(data){
                var selectedMax = selectedMaxNum || 3, selectJobCate = new ZPIDC.dialog({
                    containerid: containerid || "window_industry_dialog",//自定义的id属性
                    containerCls : 'window_container_border',//容器最外框样式
                    headerHeight : '0px'//头高度
                });
                selectJobCate.optionBody(data);//把你的内容填入即可
                if(isMultiSelect){
                    var tip = language == 1 ? '最多可选项' + selectedMax : 'Most selection ' + selectedMax;
                    $('#__layer_wrapper__ h4 ').append('<small>' + tip +'</small>');
                    /*多选时为了使下边线对其，调整第一列的高度*/
                    if(language == 2){
                        var hackP = $("#layer_div_job_cate_class").next("div").find("p");
                        $(hackP[2]).css({height:'122px',lineHeight:'122px'});
                        $(hackP[8]).css({height:'91px',lineHeight:'91px'});
                        $(hackP[9]).css({height:'153px',lineHeight:'153px'});
                        $(hackP[11]).css({height:'273px',lineHeight:'273px'});
                        $(hackP[12]).css({height:'152px',lineHeight:'152px'});
                    }
                }
                document.getElementById("layer_div_job_cate_class").style.display="none";
                var jobCate = new zpJobCateMgr();
                jobCate.isMultiSelect = isMultiSelect || false;
                jobCate.selectedMaxNum = selectedMax;
                jobCate.show(showNamesElemId, showIdsElemId,showParentIdsElemId,
                    function(){
                        typeof confimFun == 'function' ? confimFun() : '';
                        selectJobCate.onclose();
                    }, function(){
                        typeof cancelFun == 'function' ? cancelFun() : '';
                        selectJobCate.onclose();
                });
                /*控件显示后修改划过效果*/
                $(".ul_job_cate_parent_css li").on("mouseover",function(){
                    $(this).css("background","#f8f8f8").siblings().css("background","#fff");
                    $(this).css("borderRight","1px solid #f8f8f8").siblings().css("borderRight","1px solid #e5e5e5");
                })
            }
        });
    }
    /*$postionCate.on('click',function(){
        $(this).industryCreator('window_position_cate_selector',false,null,'job_type','subJobType','SchJobType',callBack_jobPrevious, callBack_jobPrevious);
    });*/
    $('#industry_type').IndustryOn(language == 1 ? CONST_INDUSTRY['industry'] : CONST_INDUSTRY_EN['industry'],{
        limit:1,
        InsHiddenId:'industry_sub',
        SubHiddenId:'industry',
        callBack: callBack_industryPrevious
    });
    $(function(){
//        var language=1;
        //beg:日期控件初始化
        $('#workstart_date_y').DateLink({
            close: callBack_work_date,
            languageId:language,
            yInputId:'workstart_date_y',
            mInputId:'workstart_date_m',
            soFar: false
        });
        $('#workstart_date_m').DateLink({
            IsYear:false,
            left : '-101px',
            divClass:'month_show',
            closeM: callBack_work_date,
            languageId:language,
            yInputId:'workstart_date_y',
            mInputId:'workstart_date_m'
        });

        $('#workend_date_y').DateLink({
            left : '-230px',
            close: callBack_work_date,
            languageId:language,
            yInputId:'workend_date_y',
            mInputId:'workend_date_m',
            soFar:true
        });
        $('#workend_date_m').DateLink({
            left : '-331px',
            IsYear:false,
            divClass:'month_show',
            closeM: callBack_work_date,
            languageId:language,
            yInputId:'workend_date_y',
            mInputId:'workend_date_m'
        });

    })
    //end:日期控件初始化
    /*教育经历 - 就读时间 日期控件初始化*/
    $(function(){
//        var language=1;
        $('#study_start_date_y').DateLink({
            close: callBack_study_dateY,
            languageId:language,
            yInputId:'study_start_date_y',
            mInputId:'study_start_date_m',
            soFar: false
        });
        $('#study_start_date_m').DateLink({
            IsYear:false,
            left : '-101px',
            divClass:'month_show',
            closeM: callBack_study_date,
            languageId:language,
            yInputId:'study_start_date_y',
            mInputId:'study_start_date_m'
        });

        $('#study_end_date_y').DateLink({
            left : '-230px',
            close:callBack_study_date,
            languageId:language,
            yInputId:'study_end_date_y',
            mInputId:'study_end_date_m',
            soFar: true
        });
        $('#study_end_date_m').DateLink({
            left : '-331px',
            IsYear:false,
            divClass:'month_show',
            closeM: callBack_study_date,
            languageId:language,
            yInputId:'study_end_date_y',
            mInputId:'study_end_date_m'
        });

    })
    /*求职意向 - 期望工作地点*/
    $('#desired_City').seleteCity({
        isMultipleChoice: true,
        limit:3,
        isForeignList : true,
        closeCallback: callBack_placeDesired,
        language:language
    });
    /*求职意向 - 期望从事行业*/
    $('#button_industryF').IndustryOn(language == 1 ? CONST_INDUSTRY['industry'] : CONST_INDUSTRY_EN['industry'],{
        limit:3,
        InsHiddenId:'desired_Industry_super',
        SubHiddenId:'desired_Industry',
        callBack: callBack_industryDesired
    });
    /*求职意向 - 期望从事职业*/
    var $desiredJobtypeDiv = $('#desired_Jobtype_div');
    $desiredJobtypeDiv.on('click', function(){
        $(this).industryCreator('window_position_cate_selector',true,3,'desired_Jobtype_show','desired_Jobtype','desired_Jobtype_id',callBack_jobDesired,callBack_jobDesired);
    });
    /*教育经历 - 学校名称*/
    $("#school_name").autoSchoolName({
        language:language,
        callback : callBack_schoolName
    });
    /*教育经历 - 专业名称*/
    $("#profession_name").autoMajorName({
        language:language,
        callback : callBack_professionName
    });
})(window.document,jQuery);